package SaleManagerRmi;

import java.rmi.Naming;
import java.rmi.RemoteException;
import POJO.*;

public class SaleManagerRmi implements RmiInterface{
RmiInterface rmiInterface;
	
	public void init() {
		try {   
            String url = "//localhost:8806/SAMPLE-SERVER1";   
            rmiInterface = (RmiInterface) Naming.lookup(url);
        } catch (RemoteException rex) {   
            System.out.println("Error in lookup: " + rex.toString());   
        } catch (java.net.MalformedURLException me) {   
            System.out.println("Malformed URL: " + me.toString());   
        } catch (java.rmi.NotBoundException ne) {   
            System.out.println("NotBound: " + ne.toString());   
        }
	}
	
	public SignInStatePOJO findSaleManager(SignInPOJO signInPOJO) {
		try {
			return rmiInterface.findSaleManager(signInPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public DisplayCustomerPOJO findCustomerList() {
		try {
			return rmiInterface.findCustomerList();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public DisplayCustomerPOJO findCustomerList(String s) {
		try {
			return rmiInterface.findCustomerList(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void updateCustomerPromotionInfo(CustomerPromotionInfoPOJO customerPromotionInfoPOJO) {
		try {
			rmiInterface.updateCustomerPromotionInfo(customerPromotionInfoPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public OrderListPOJO findOrder() {
		try {
			return rmiInterface.findOrder();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public OrderListPOJO findOrder(String s) {
		try {
			return rmiInterface.findOrder(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void updateOrder(OrderPOJO orderPOJO) {
		try {
			rmiInterface.updateOrder(orderPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public CategoryListPOJO findCategoryList() {
		try {
			return rmiInterface.findCategoryList();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public CategoryStatePOJO insertCategory(CategoryPOJO categoryPOJO) {
		try {
			return rmiInterface.insertCategory(categoryPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void deleteCategory(String s) {
		try {
			rmiInterface.deleteCategory(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public CategoryStatePOJO updateCategory(CategoryPOJO categoryPOJO) {
		try {
			return rmiInterface.updateCategory(categoryPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public BookListPOJO findBookList() {
		try {
			return rmiInterface.findBookList();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public BookStatePOJO insertBook(BookPOJO bookPOJO) {
		try {
			return rmiInterface.insertBook(bookPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void deleteBook(String s) {
		try {
			rmiInterface.deleteBook(s);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public BookStatePOJO updateBook(BookPOJO bookPOJO) {
		try {
			return rmiInterface.updateBook(bookPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
}
